package br.org.isvi.interpretador.portugol.access;

import java.util.HashMap;
import java.util.List;

import org.apache.cayenne.exp.Expression;
import org.apache.cayenne.query.SelectQuery;

import br.org.isvi.interpretador.portugol.model.Aluno;
import br.org.isvi.interpretador.portugol.model.Professor;
import br.org.isvi.interpretador.portugol.model.SolucaoAluno;

public class ProfessorDAO extends AbstractDAO<Professor> {

	@Override
	public Class<Professor> getType() {
		return Professor.class;
	}

	@SuppressWarnings("unchecked")
	public Professor porLogin (String login) {
			List<Professor> ret;
			HashMap<String, String> map = new HashMap<String, String>();
			map.put("loginStr", login);
			
			SelectQuery query = new SelectQuery(Professor.class, Expression.fromString("login like $loginStr").
					expWithParameters(map));
			
			ret = getCtx().performQuery(query);
			
			return ret.size()>0? ret.get(0):null;
	}
	
}
